<html>
<head>
<title>Demo</title>
<body>
<ul>
<li><a href="#1">MATRIX IN JAVA</a>
<li><a href="#2">Here are the imports</a>
<li><a href="#3">Where it asks size of matrix</a>
<li><a href="#4">Printint the matrix</a>
</ul>

<p>

</p>
<a name="1"></a><h2>MATRIX IN JAVA</h2>
<p>

</p>
<li>Zach Cowell - zcowell
<li>CS 110 LAB
<li>Dec 6, 2007
<li>Brandi Shafer
<li>Program: Matrix.java

<p>


</p>
<a name="2"></a><h2>Here are the imports</h2>
<pre>
 import java.io.*;
 import java.util.*;
</pre>
<p>

</p>
<pre>
 public class Matrix {
    public static void main (String [] args){
      FileOutputStream out; 
</pre>
<p>
declare a file output object
</p>
<pre>
      PrintStream p; 
</pre>
<p>
declare a print stream object

</p>
<pre>
                try
                {
</pre>
<p>
Create a new file output stream
connected to "myfile.txt"
</p>
<pre>
                        out = new FileOutputStream("tests/tmp/outfile");
</pre>
<p>
Connect print stream to the output stream
</p>
<pre>
                        p = new PrintStream( out );
   int[][] board,board2;
   Scanner in = new Scanner(System.in);
</pre>
<a name="3"></a><h2>Where it asks size of matrix</h2>
<pre>
   System.out.println("Please input the size of your matrix:");
   int size = in.nextInt();
   int ROWS = size;
   int COLUMNS = size;
      
   board = new int[ROWS][COLUMNS];
   board2 = new int[ROWS][COLUMNS];
</pre>
<a name="4"></a><h2>Printint the matrix</h2>
<p>
This is where the matrix is printed  
</p>
<pre>
   System.out.println();
      for (int i = 0; i < ROWS; i++){
        for (int j = 0; j < COLUMNS; j++){
          System.out.println("Please enter element "+ i+"," +j +" of the first matrix."); 
          board[i][j] = in.nextInt();
        }}
      
         for (int i = 0; i < ROWS; i++){
        for (int j = 0; j < COLUMNS; j++){
          System.out.println("Please enter element "+i+"," +j + " of the second matrix."); 
          board2[i][j] = in.nextInt();
        }}   
   System.out.println();
    for (int i = 0; i < ROWS; i++){
      p.println();
        for (int j = 0; j < COLUMNS; j++){
          p.print(board[i][j] + board2[i][j] + " "); 
             
        }}   
</pre>
<p>

</p>
<pre>
                        p.close();    
  }
                catch (Exception e)
                {
                        System.err.println ("Error writing to file");
                }
 
    }}</pre>
</body>
</html>